package com.cet.designapplication.prototype;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.*;

/**
 * @author NSOC
 */

@Data
@NoArgsConstructor
public class Teacher implements Serializable {

    private String teacherName;

    private Student student;

    public Teacher copy() {
        try {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
            objectOutputStream.writeObject(this);

            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
            ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
            return (Teacher) objectInputStream.readObject();
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e.getMessage());
        }
    }
}
